package org.example.core.mysql.convert;

import org.example.core.exception.ErrorException;

import java.math.BigDecimal;

/**
 * Description:
 * Date: 2024/2/15 12:01
 */
public class DoubleToBigDecimalConvert extends AbstractConvert {
    @Override
    public Object convert(Object value) {
        if (value instanceof Double) {
            return BigDecimal.valueOf((Double) value);
        }
        if (value instanceof BigDecimal) {
            return ((BigDecimal) value).doubleValue();
        }
        throw new ErrorException("转换失败！");
    }
}
